package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbReportCash;
import com.ruoyi.supplier.service.ITbReportCashService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每日收入账Controller
 * 
 * @author oliver.li
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/supplier/reportCash")
public class TbReportCashController extends BaseController
{
    @Autowired
    private ITbReportCashService tbReportCashService;

    /**
     * 查询每日收入账列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportCash:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbReportCash tbReportCash)
    {
        startPage();
        List<TbReportCash> list = tbReportCashService.selectTbReportCashList(tbReportCash);
        return getDataTable(list);
    }

    /**
     * 导出每日收入账列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportCash:export')")
    @Log(title = "每日收入账", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbReportCash tbReportCash)
    {
        List<TbReportCash> list = tbReportCashService.selectTbReportCashList(tbReportCash);
        ExcelUtil<TbReportCash> util = new ExcelUtil<TbReportCash>(TbReportCash.class);
        return util.exportExcel(list, "每日收入账数据");
    }

    /**
     * 获取每日收入账详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportCash:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbReportCashService.selectTbReportCashById(id));
    }

    /**
     * 新增每日收入账
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportCash:add')")
    @Log(title = "每日收入账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbReportCash tbReportCash)
    {
        return toAjax(tbReportCashService.insertTbReportCash(tbReportCash));
    }

    /**
     * 修改每日收入账
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportCash:edit')")
    @Log(title = "每日收入账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbReportCash tbReportCash)
    {
        return toAjax(tbReportCashService.updateTbReportCash(tbReportCash));
    }

    /**
     * 删除每日收入账
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportCash:remove')")
    @Log(title = "每日收入账", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbReportCashService.deleteTbReportCashByIds(ids));
    }
}
